<template>
  <transition name="fade">
    <div v-if="show" style="left:0;right:0;width:100%;height:100%;position:fixed;display:flex;align-items:center;justify-content:center;top:0;">
      <div class="toast-content">
        <div class="toast-content-wrapper">
          <div style="display:flex;justify-content:center;">
            <svg-icon class="svg-icon" :icon-class="iconClass" />
          </div>
          <div class="toast-text">
            {{ message }}
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'Toast',
  props: {
    show: {
      type: Boolean
    },
    iconClass: {
      type: String
    },
    message: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  data() {
    return {
    }
  },
  watch: {
    show(val) {
      this.disapper()
    }
  },
  mounted() {

  },
  methods: {
    disapper() {
      if (this.show) {
        setTimeout(() => {
          this.$emit('changeState', !this.show)
        }, 2000)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.toast-content{
    position: absolute;
    // left: 50%;
    // top: 50%;
    background:rgba(3, 14, 44, 0.85);
    padding:40px 32px;
    border-radius: 5px;
    // transform: translate(-50%, -50%);
    color: #909399;
    overflow: hidden;
    display: flex;
    align-items: center;
    border-radius: 24px;
}
.fade-enter-active, .fade-leave-active {
  transition: opacity .5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
.toast-text{
    margin-top:24px;
    font-size: 30px;
    font-weight: 400;
    color: #FFFFFF;
    flex-shrink: 0;
}

.svg-icon{
    width:40px;
    height:40px;
}
</style>
